

	/*******************************************************************************
*   			Impacts of a Large-Scale Parenting Program: 				   *
*					Experimental Evidence from Chile						   *
********************************************************************************


	REQUIRES:	"${dt_final}baseline_for figures.dta"
	CREATES:	${out_tables}/T4A_basebalance_parent.xls
				
	WRITEN BY:  Italo Lopez  [italolop@usc.edu]

********************************************************************************
	Prepare data
*******************************************************************************/

	* Load data
	use "$dt_int/baseline_for figures.dta", clear


	* Establish macros for regressions



/*******************************************************************************
Table A4: Baseline balance: parental beliefs, mental health, and investments in children
*******************************************************************************/
	* Rename relevant variables
	*---------------------------------

	
	gen Evalplsivtot3=. 
    replace Evalplsivtot3=1 if t_per<=2 & t_per!=.
    replace Evalplsivtot3=2 if inrange(t_per,3,15) & t_per!=.
	replace Evalplsivtot3=3 if t_per>=16 & t_per!=.
	gen Evalplsivaud3=. 
    replace Evalplsivaud3=1 if  percentil_aud<=2 & t_per!=.
    replace Evalplsivaud3=2 if inrange( percentil_aud,3,15) & t_per!=.
	replace Evalplsivaud3=3 if  percentil_aud>=16 & t_per!=.
	gen Evalplsivexp3=. 
    replace Evalplsivexp3=1 if  percentil_e<=2 & t_per!=.
    replace Evalplsivexp3=2 if inrange( percentil_e,3,15) & t_per!=.
	replace Evalplsivexp3=3 if  percentil_e>=16 & t_per!=.
	tabulate Evalplsivtot3, g(plst)
	tabulate Evalplsivaud3, g(plsa)
	tabulate Evalplsivexp3, g(plse)
	g t_score_rec=ss_audi_PLSIV if t_per!=.
	g t_score_exp=ss_expre_PLSIV if t_per!=.

	* CBCL
	tabstat  ach_ttot, by(TIPO) s(mean sd)
	tabstat  ach_tint, by(TIPO) s(mean sd)
	tabstat  ach_text, by(TIPO) s(mean sd)

	tabulate ach_tot_3lev, g(acht)
	tabulate ach_int_3lev, g(achi)
	tabulate ach_ext_3lev, g(ache)

	*DCCS
	forvalues i=3/6 {

	g DCCSPunt`i'=DCCSPunt_old if  edadtramos==`i'
	g DCCS_pass`i'=DCCS_pass_old if  edadtramos==`i'
	tabulate DCCS_pass`i', g(dccs`i')

	}


gen  PBC_Discipl_old= PBC_Dneg_old + PBC_Dpos_old + PBC_Dmakefeel_old
gen FOLIO_UC=FOLIO_UC_old

bys FOLIO_UC: gen o=_n

iebaltab arian_bin_eap ative_bin_eap perm_bin_eap PSCS PSSS_others PSI CESD fci_pc_eap PBC_Nurtur  PBC_Discipl if o==1, grpvar(TIPO) save("${out_tables}/appendix/T4A_basebalance_parent.xlsx") ftest fmissok pttest pftest total replace



import excel using "${out_tables}/appendix/T4A_basebalance_parent.xlsx", clear

gen row = _n 
br
replace A = "Authoritative style (IRT score)" if row == 4
replace A = "Authoritarian style (IRT score)" if row == 6 
replace A = "Permissive style (IRT score)" if row == 8 
replace A = "Perceived Self-efficacy" if row == 10
replace A = "Perceived Social Support" if row == 12
replace A = "Parental Stress" if row == 14
replace A = "Depression" if row == 16
replace A = "Home Index (Family Care	Indicators scale)" if row == 18
replace A = "Socio-emotional stimulation (PBC Nurturing Raw scale)" if row == 20
replace A = "Use of disciplinary strategies (PBC Discipline raw scale)" if row == 22

drop L row

	

export  excel using "${out_tables}/appendix/T4A_basebalance_parent.xlsx", replace

